//
// +---------------------------------------------------------------------------------+
// | Package: EezeeSite Client                                                       |
// +---------------------------------------------------------------------------------+
// | Copyright (C) 2006  EezeeSite Development Team                                  |
// +---------------------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or                   |
// | modify it under the terms of the GNU General Public License                     |
// | as published by the Free Software Foundation; either version 2                  |
// | of the License, or (at your option) any later version.                          |
// |                                                                                 |
// | This program is distributed in the hope that it will be useful,                 |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                  |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                   |
// | GNU General Public License for more details.                                    |
// |                                                                                 |
// | You should have received a copy of the GNU General Public License               |
// | along with this program; if not, write to the Free Software                     |
// | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. |
// +---------------------------------------------------------------------------------+
// | Author: Mayukh De <mayukhde@gmail.com>                                          |
// +---------------------------------------------------------------------------------+
//
		function toggleElement(strElement, blnVisible) {
			var objStyle = document.getElementById(strElement).style;
			if (objStyle) {
				objStyle.display = (blnVisible == 1) ? 'block' : 'none';
			}
		}
		
		function authStatus() {
			var objAuth = getAuthObj();
            objAuth.authStatus();
		}
		
		function showLoginBox() {
            showFloat();
            showFloatingContent('Log In', 'loginbox');
            return false;
		}
        
        function showPasswordReminderBox() {
			hideFloatingContent('loginbox');
            showFloatingContent('Forgot Your Password?', 'passwordreminder');
            return false;
		}
		
		function logIn(form) {
			if (validate_logInForm(form)) {
                var objAuth = getAuthObj();
                var input = new Object();
                for(var i = 0; i < form.elements.length; i++) {
                    if (form.elements[i].name) {
                        input[form.elements[i].name] = form.elements[i].value;
                    }
                }
                objAuth.logIn(input);
            }
		}
		
		function logOut() {
            var objAuth = getAuthObj();
            objAuth.logOut();
		}
        
        function passwordReminder(form) {
			if (validate_passwordReminderForm(form)) {
                var objAuth = getAuthObj();
                var input = new Object();
                for(var i = 0; i < form.elements.length; i++) {
                    if (form.elements[i].name) {
                        input[form.elements[i].name] = form.elements[i].value;
                    }
                }            
                objAuth.passwordReminder(input);
            }        
        }
		
        function getAuthObj() {
            var objCallback = { validate: function() {} };
            var objAuth = new esauthenticationmodeajax(objCallback);
            return objAuth;        
        }
        
        function initESClient() {
            var objCallback = { validate: function() {} };
            var objInit = new essystemclientcheckmodeajax(objCallback);
            objInit.initESClient();
        }
        
        function loader() {
            var objLoading = document.getElementById("HTML_AJAX_LOADING");
            objLoading.style.height = document.documentElement.scrollHeight + "px";
        }
		
		function showFloat() {
			var objCallback = { validate: function() {} };
			var objFloat = document.getElementById("floatingBox");
			objFloat.style.left = ((document.documentElement.scrollWidth)/2)-250 + "px";
			Effect.toggle('floatingBox', 'appear');
            return false;
		}
        
        function hideFloat() {
            Effect.toggle('floatingBox', 'appear');
            return false;
        }
        
        function showFloatingContent(title, content) {
            document.getElementById('floatingTitle').innerHTML = title;
            Effect.toggle(content, 'slide');
            return false;
        }
        
        function hideFloatingContent(content) {
            Effect.toggle(content, 'slide');
            return false;
        }
        
        function submitForm(name) {
            document.forms[name].submit();
        }
		
		/*if(document.getElementById) {
	        window.alert = function(string) {
		        ESAlert(string);
	        }
        }
        
        function ESAlert(string) {
            objAlertBody = document.getElementsByTagName("body")[0].appendChild(document.createElement("div"));
	        objAlertBody.id = "alertContainer";
			objAlertBody.style.height = document.documentElement.scrollHeight + "px";
			objAlert = objAlertBody.appendChild(document.createElement("div"));
	        objAlert.id = "alertBox";
			objAlert.style.left = (document.documentElement.scrollWidth)/2 + "px";
			h1 = objAlert.appendChild(document.createElement("h4"));
	        h1.appendChild(document.createTextNode("EezeeSite Application"));
			msg = objAlert.appendChild(document.createElement("div"));
	        msg.appendChild(document.createTextNode(string));			
			btn = objAlert.appendChild(document.createElement("button"));
	        btn.id = "closeBtn";
	        btn.appendChild(document.createTextNode("OK"));
	        btn.href = "#";
            btn.onclick = function() { removeESAlert();return false; }
        }
		
		function removeESAlert() {
            document.getElementsByTagName("body")[0].removeChild(document.getElementById("alertContainer"));
        }*/